package main

import (
	"context"
	"flag"
	"fmt"
	"github.com/zeromicro/go-zero/core/conf"
	"github.com/zeromicro/go-zero/mcp"
)

var configFile = flag.String("f", "etc/config.yaml", "配置文件")

const fileContent = `package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
`

// Example MCP server demonstrating tool, prompt, and resource registration
func main() {
	// Load configuration from YAML file
	var c mcp.McpConf
	conf.MustLoad(*configFile, &c)

	// Create MCP server
	server := mcp.NewMcpServer(c)
	defer server.Stop()

	goResource := mcp.Resource{
		Name:        "go-example",
		URI:         "file:///project/src/main.go",
		Description: "A simple Go example with multiple files",
		Handler: func(ctx context.Context) (mcp.ResourceContent, error) {
			return mcp.ResourceContent{
				MimeType: "text/x-go",
				Text:     fileContent,
			}, nil
		},
	}
	server.RegisterResource(goResource)

	fmt.Printf("Starting MCP server on :%d\n", c.Port)
	defer server.Stop()
	server.Start()
}
